
/* GENERATED CODE:
 *  Any modifications you make are guaranteed
 *  to be deleted when this is regenerated.
 * Please edit "PROTOCOLS" inside this directory
 *
 * Names are all upper case because of "String" and "string."
 */

using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
using OWED.Network.Messages.General;
using OWED.Network.Messages;
using OWED.Network.Messages.Reply;


namespace OWED.Network.Messages.General
{
	public class Tag: IProtocolItem 
	{
		List <Attribute> my_Attributes;
		String my_name;
		public Tag (String name, List <Attribute> Attributes)
		{
			my_name = name;
			my_Attributes = Attributes;
		}
		public List <Attribute> Attributes { get { return my_Attributes; } }
		public String name { get { return my_name; } }


		public static new Tag FromXml(XmlDocument xml)
		{
			String name = xml.SelectSingleNode("Tag").Attributes.GetNamedItem("name").Value;
			XmlDocument doc;
			if (true) {
				XmlNodeList list_Attributes = xml.SelectNodes("Tag/Attribute");
				List <Attribute> Attributes = new List <Attribute>();
				foreach (XmlNode node in list_Attributes) {
					doc = new XmlDocument();
					doc.AppendChild(doc.ImportNode(node, true));
					Attributes.Add(Attribute.FromXml(doc));
				}

				return new Tag(name, Attributes);
			}
		}


		public override XmlDocument ToXml()		{
			XmlDocument doc = new XmlDocument();

			doc.AppendChild(doc.CreateElement("Tag"));
			XmlAttribute attr;
			attr = doc.CreateAttribute("name");
			attr.Value = my_name;
			doc.FirstChild.Attributes.Append(attr);


			if (my_Attributes != null) {
				XmlNode node;
				foreach (Attribute item in my_Attributes) {
					node = doc.ImportNode(item.ToXml().FirstChild, true);
					doc.FirstChild.AppendChild(node);
				}
			}

			return doc;
		}
	}
}
